<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog ms-modal-dialog" style="width: 800px; margin-top: 100px;">
  <div class="modal-content">
  
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">修改司机个人信息</h4>
    </div>

    <div class="modal-body">

      <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/drivers/${driver.id}/edit-profile">
  
        <input type="hidden" name="_method" value="PATCH"> 
        <input type="hidden" name="driverId" value="${driver.id}"> 
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2">文化程度：</label>
          <div class="col-xs-3 pull-left">
            <select name="educationLevel" class="select2 form-control" tabindex="5">
              <option></option>
              <c:forEach items="${selection.masterData['EDUCATION']}" var="education">
                <option value="${education.code}" ${driver.educationLevel eq education.code ? 'selected' : ''}>${education.value}</option>
              </c:forEach>
            </select>
          </div>
  
          <label class="control-label col-xs-2">政治面貌：</label>
          <div class="col-xs-3 pull-left">
            <select name="clanId" class="select2 form-control" tabindex="9">
              <option></option>
              <c:forEach items="${selection.masterData['PARTY']}" var="party">
                <option value="${party.code}" ${driver.clanId eq party.code ? 'selected' : ''}>${party.value}</option>
              </c:forEach>
            </select>
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2">专业：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="speciality" class="form-control" value="${driver.speciality}" tabindex="13" autocomplete="off" />
          </div>
  
          <label class="control-label col-xs-2">何时加入：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="joinDate" class="form-control date" value="<fmt:formatDate value="${driver.joinDate}" pattern="yyyy-MM-dd"/>" tabindex="10" autocomplete="off" />
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2">毕业学校：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="school" class="form-control" value="${driver.school}" tabindex="12" autocomplete="off" />
          </div>
  
          <label class="control-label col-xs-2">学位：</label>
          <div class="col-xs-3 pull-left">
            <select name="degreeId" class="select2 form-control" tabindex="14">
              <option></option>
              <c:forEach items="${selection.masterData['DEGREE']}" var="degree">
                <option value="${degree.code}" ${driver.degreeId eq degree.code ? 'selected' : ''}>${degree.value}</option>
              </c:forEach>
            </select>
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2">毕业年月：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="graduateDate" class="form-control date" value="<fmt:formatDate value="${driver.graduateDate}" pattern="yyyy-MM-dd"/>" tabindex="15" autocomplete="off" />
          </div>
  
          <label class="control-label col-xs-2">家庭地址：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="homeAddress" class="form-control" value="${driver.homeAddress}" tabindex="16" autocomplete="off" />
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2">家庭邮政编码：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="homeZipcode" data-validate="number" class="form-control" value="${driver.homeZipcode}" tabindex="17" autocomplete="off" />
          </div>
  
          <label class="control-label col-xs-2">联系地址：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="contactAddress" class="form-control" value="${driver.contactAddress}" tabindex="18" autocomplete="off" />
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
  
          <label class="control-label col-xs-2">联系邮政编码：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="contactZipcode" data-validate="number" class="form-control" value="${driver.contactZipcode}" tabindex="19" autocomplete="off" />
          </div>
  
          <label class="control-label col-xs-2">联系人姓名：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="contactorName" class="form-control" value="${driver.contactorName}" tabindex="20" autocomplete="off" />
          </div>
  
        </div>
  
        <div class="form-group  ms-form-group">
  
          <label class="control-label col-xs-2">称谓：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="contactorAppellation" class="form-control" value="${driver.contactorAppellation}" tabindex="21" autocomplete="off" />
          </div>
  
          <label class="control-label col-xs-2">固定电话：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="tel" class="form-control" value="${driver.tel}" tabindex="23" autocomplete="off" />
          </div>
  
        </div>
  
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">备注：</label>
          <div class="pull-left col-xs-8">
            <textarea name="description" rows="5" style="width: 100%;" tabindex="24">${driver.description}</textarea>
          </div>
        </div>
  
        <div class="modal-footer ms-modal-footer">
          <button type="submit" class="btn ms-btn btn-primary">确定</button>
          <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
        </div>      
  
      </form>
    
    </div>

  </div>
</div>

<script type="text/javascript">
  $(document).ready(function(){
    
    $('select[name="educationLevel"]').select2({
      placeholder: '请选择文化程度',
      minimumResultsForSearch: -1,
      allowClear: true,
    });
    
    $('select[name="clanId"]').select2({
      placeholder: '请选择政治面貌',
      minimumResultsForSearch: -1,
      allowClear: true,
    });

    $('select[name="degreeId"]').select2({
      placeholder: '请选择学位',
      minimumResultsForSearch: -1,
      allowClear: true,
    });
    
  });
</script>